﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace YiLe.BLL.Service
{
    public interface IService<TEntity, TId>
    {
        /// <summary>
        /// Finds entity with given id.
        /// </summary>
        /// <param name="id">The id to search with.</param>
        /// <returns>Found entity or null if not found.</returns>
        TEntity Get(TId id);

        /// <summary>
        /// Returns all entities of given type.
        /// The result may be different than in database based on
        /// filters or other locked search criteria for search.
        /// </summary>
        /// <returns></returns>
        IList<TEntity> GetAll();

        /// <summary>
        /// Saves the given entity.
        /// </summary>
        /// <param name="entity">Entity to save.</param>
        /// <returns>The id for saved entity.</returns>
        TId Save(TEntity entity);

        /// <summary>
        /// Saves or updates the entity. Behavior depends on the current state of entity's ID.
        /// </summary>
        /// <param name="entity">Entity to save or update.</param>
        void Update(TEntity entity);

        /// <summary>
        /// Deletes the entity.
        /// </summary>
        /// <param name="entity">Entity to delete.</param>
        void Delete(TEntity entity);
    }
}
